package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.model.UmsAgentApply;
import com.fc.mall.portal.dto.UmsAgentApplyParam;
import com.fc.mall.portal.service.SmsService;
import com.fc.mall.portal.service.UmsAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Sunny on 2019/7/17.
 */
@RestController
@RequestMapping("/agent")
public class UmsAgentController {

    @Autowired
    private UmsAgentService umsAgentService;

    @Autowired
    private SmsService smsService;


    @PostMapping
    public Result handleApplyAgent(@RequestBody UmsAgentApplyParam agentApply)
    {
        umsAgentService.applyAgent(agentApply);
        return Result.success();
    }

    @GetMapping("{phone}/generate")
    public Result handleGenerateCode(@PathVariable String phone)
    {
        return Result.success(smsService.sendSms(phone));
    }

    @GetMapping
    public Result handleGetApply()
    {
        UmsAgentApply agentApply = umsAgentService.getApplyAgent();
        return  Result.success(null != agentApply);
    }

}
